package cn.sccdlg.ssm.dao;

import cn.sccdlg.ssm.domain.SysLog;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author RaoShuang
 * @emil 991207823@qq.com
 * @date 2020/10/27 21:35
 * 系统日志持久层
 */
@Repository
@Mapper
public interface ISysLogDao {

    /**
     * 保存系统日志
     * @param sysLog 日志信息
     */
    @Insert("INSERT INTO syslog(id,visitTime,username,ip,url,executionTime,method) " +
            "VALUES(#{id},#{visitTime},#{username},#{ip},#{url},#{executionTime},#{method})")
    void save(SysLog sysLog) throws Exception;

    /**
     * 按照起至条数分页查询日志
     * @param start 分页起点
     * @param end 分页终点
     */
    @Select("SELECT * FROM sysLog LIMIT #{start},#{end}")
    List<SysLog> findList(@Param("start")int start, @Param("end") int end) throws Exception;

    /**
     * 查询所有日志信息
     */
    @Select("SELECT * FROM sysLog")
    List<SysLog> findAll() throws Exception;

}
